/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrmRoladorMascara.java
 *
 * Created on 30/09/2011, 09:10:58
 */
package dados.storyteller.vampiro;

import javax.swing.JOptionPane;
import javax.swing.SpinnerNumberModel;
import viewer.FrmPrincipal;

/**
 *
 * @author yurifw
 */
public class FrmRoladorMascara extends javax.swing.JInternalFrame {

    /** Creates new form FrmRoladorMascara */
    public FrmRoladorMascara() {
        initComponents();


    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        lblEspeciaizacao = new javax.swing.JLabel();
        radioNao = new javax.swing.JRadioButton();
        radioSim = new javax.swing.JRadioButton();
        lblDificuldade = new javax.swing.JLabel();
        lblParadaDados = new javax.swing.JLabel();
        txtParadaDados = new javax.swing.JTextField();
        btoRolar = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtRolagem = new javax.swing.JTextArea();
        lblSucessos = new javax.swing.JLabel();
        lblSucessos2 = new javax.swing.JLabel();
        lblFalhaCritica = new javax.swing.JLabel();
        btoSair = new javax.swing.JButton();
        spnDif = new javax.swing.JSpinner();

        buttonGroup1.add(radioNao);
        buttonGroup1.add(radioSim);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Rolador de Dados - A Mascara");

        lblEspeciaizacao.setText("Usar especialização?");

        radioNao.setText("Não");

        radioSim.setText("Sim");

        lblDificuldade.setText("Dificuldade:");

        lblParadaDados.setText("Parada de Dados:");

        btoRolar.setText("Rolar");
        btoRolar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btoRolarActionPerformed(evt);
            }
        });

        txtRolagem.setColumns(20);
        txtRolagem.setRows(5);
        txtRolagem.setLineWrap(true);
        txtRolagem.setWrapStyleWord(true);
        jScrollPane1.setViewportView(txtRolagem);

        lblSucessos.setText("Sucessos:");

        lblFalhaCritica.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        lblFalhaCritica.setForeground(new java.awt.Color(204, 0, 0));
        lblFalhaCritica.setText("FALHA CRITICA");
        lblFalhaCritica.setVisible(false);

        btoSair.setText("x");
        btoSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btoSairActionPerformed(evt);
            }
        });

        spnDif.setModel(new SpinnerNumberModel(6, 1, 10, 1));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(50, 50, 50)
                        .addComponent(lblParadaDados)
                        .addGap(4, 4, 4)
                        .addComponent(txtParadaDados, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(200, 200, 200)
                        .addComponent(btoRolar))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(50, 50, 50)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 528, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(510, 510, 510)
                        .addComponent(btoSair))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(50, 50, 50)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(lblDificuldade)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(spnDif))
                            .addComponent(lblEspeciaizacao, javax.swing.GroupLayout.Alignment.LEADING))
                        .addGap(12, 12, 12)
                        .addComponent(radioSim)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(radioNao)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(50, 50, 50)
                .addComponent(lblSucessos)
                .addGap(2, 2, 2)
                .addComponent(lblSucessos2, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(lblFalhaCritica)
                .addGap(33, 33, 33))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(50, 50, 50)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblEspeciaizacao)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(radioSim)
                        .addComponent(radioNao)))
                .addGap(17, 17, 17)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblDificuldade)
                    .addComponent(spnDif, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblParadaDados)
                    .addComponent(txtParadaDados, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addComponent(btoRolar)
                .addGap(7, 7, 7)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblFalhaCritica)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(lblSucessos2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lblSucessos, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(23, 23, 23)
                .addComponent(btoSair)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btoRolarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btoRolarActionPerformed
        // Botao Rolar
        int parada = Integer.parseInt(txtParadaDados.getText());
        int dif = Integer.parseInt(spnDif.getValue().toString());
        boolean especializacao = false;
        if (radioSim.isSelected()) {
            especializacao = true;
        } else if (radioNao.isSelected()) {
            especializacao = false;
        } else {
            JOptionPane.showMessageDialog(null, "Selecione uma opção para especialização", "Erro", JOptionPane.ERROR_MESSAGE);
        }
        RoladorDeDados rolar = new RoladorDeDados();
        String rolagem[] = rolar.mascara(especializacao, parada, dif);
        txtRolagem.setText(rolagem[0]);
        lblSucessos2.setText(rolagem[1]);
        if (rolagem[2].equals("critico")) {
            lblFalhaCritica.setVisible(true);
        }
    }//GEN-LAST:event_btoRolarActionPerformed

    private void btoSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btoSairActionPerformed
        FrmPrincipal.mnuRoladorMascara.setEnabled(true);
        dispose();
    }//GEN-LAST:event_btoSairActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FrmRoladorMascara().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btoRolar;
    private javax.swing.JButton btoSair;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblDificuldade;
    private javax.swing.JLabel lblEspeciaizacao;
    private javax.swing.JLabel lblFalhaCritica;
    private javax.swing.JLabel lblParadaDados;
    private javax.swing.JLabel lblSucessos;
    private javax.swing.JLabel lblSucessos2;
    private javax.swing.JRadioButton radioNao;
    private javax.swing.JRadioButton radioSim;
    private javax.swing.JSpinner spnDif;
    private javax.swing.JTextField txtParadaDados;
    private javax.swing.JTextArea txtRolagem;
    // End of variables declaration//GEN-END:variables
}
